const app = getApp()
Page({
  data: {

  },
  onLoad: function () {
    that=this;
    wx.setNavigationBarTitle({
      title: '扫码签到'
    })
  },

  sao: function () {
    var uid = wx.getStorageSync('uid');
    wx.scanCode({
      success(res) {
        console.log(res.result)
        if (res.result) {
          var data = res.result.split(';')
          wx.request({
            url: app.globalData.baseUrl + '/course/pubRecord', // 仅为示例，并非真实的接口地址
            // url: app.globalData.url.login,
            method: 'post',
            data: {
              uid: uid,
              cid: data[0],
              time: data[1]
            },
            header: {
              "Content-Type": "application/x-www-form-urlencoded"
            },
            success: function (res) {
              console.log(res.data);
              if (res.data.code == 0) {
                wx.showToast({
                  title: res.data.msg,
                })
              }
            }
          })
        } else {
          wx.showToast({
            title: '二维码不正确',
          })
        }
      }
    })
  }
})